package com.example.travel.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ListView;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.travel.Adapter.MyAdapter;
import com.example.travel.R;
import com.example.travel.bean.AddDynamic;

import java.util.List;

import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.FindListener;

public class addFragment extends Fragment {
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.dongtai,container,false);
        Button button = view.findViewById(R.id.bt1);

        final ListView ListView1=view.findViewById(R.id.lv1);
        BmobQuery<AddDynamic> bmobQuery = new BmobQuery<AddDynamic>();
        bmobQuery.findObjects(new FindListener<AddDynamic>() {
            @Override
            public void done(List<AddDynamic> list, BmobException e) {
                if (e == null){
                    ListView1.setAdapter(new MyAdapter(getContext() , list));
                }
            }
        });
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                intent.setClassName("com.example.travel","com.example.travel.activity.AddActivity");
                startActivity(intent);
            }
        });
        return view;
}}
